package conf;

import java.util.Map;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.ext.kit.ResourceKit;
import com.jfinal.ext.plugin.tablebind.AutoTableBindPlugin;
import com.jfinal.ext.route.AutoBindRoutes;
import com.jfinal.plugin.c3p0.C3p0Plugin;

public class Conf extends JFinalConfig{

	@Override
	public void configConstant(Constants me) {
		me.setDevMode(true);
	}

	@Override
	public void configRoute(Routes me) {
		AutoBindRoutes ab =new AutoBindRoutes();
		me.add(ab);
	}

	@Override
	public void configPlugin(Plugins me) {
		Map<String,String> conf=ResourceKit.readProperties("jdbc.txt");
		C3p0Plugin c3p0Plugin = new C3p0Plugin(conf.get("jdbcUrl"),conf.get("user"), conf.get("password").trim());
		me.add(c3p0Plugin);
		
		AutoTableBindPlugin arp = new AutoTableBindPlugin(c3p0Plugin);
		arp.setDevMode(true);
		//arp.setShowSql(true);
		arp.autoScan(false);
		me.add(arp);
	}

	@Override
	public void configInterceptor(Interceptors me) {
		
	}

	@Override
	public void configHandler(Handlers me) {
		
	}
	public static void main(String[] args) {
		JFinal.start("src/main/webapp", 80, "/", 5);
	}
}
